﻿using UFSoft.UBF.Cust.ClassView.MVC.Debug;
using UFSoft.UBF.Util.Log;
using UFIDA.U9.Cust.Pub.WebSocketSharp;
using UFIDA.U9.Cust.Pub.WebSocketSharp.Server;

namespace UFSoft.UBF.Cust.ClassView.MVC.WebSocket
{
    /// <summary>
    ///     代理调试
    /// </summary>
    public class ProxyDoDebugBehavior : WebSocketBehavior
    {
        private static readonly ILogger Logger = LoggerManager.GetLogger(typeof(ProxyDoDebugBehavior));
        public static string Path = "/ClassView/ProxyDoDebug";

        public string ProxyType
        {
            get { return QueryString["proxyType"]; }
        }

        protected override void OnOpen()
        {
            base.OnOpen();
            ProxyDoDebug.Setup(ProxyType);
        }

        protected override void OnClose(CloseEventArgs e)
        {
            base.OnClose(e);
            ProxyDoDebug.Stop(ProxyType);
        }

        protected override void OnError(ErrorEventArgs e)
        {
            Logger.Error("ProxyDoDebugBehavior error" + e.Message);
        }
    }
}